home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games: Greatest Hits 1996 / Amiga Games: Greatest Hits 1996.iso / spiele / publicdomain / amigamud-tt / mystuff / hotel.m < prev    next >
Text File  |  1996-07-08  |  6KB  |  239 lines

  1. /*
  2.  * hotel.m - create hotel code
  3.  */
  4.  
  5. private tp_hotel CreateTable().
  6.  
  7. use t_util.
  8. use t_base.
  9. use t_roomTypes.
  10. use t_streets.
  11. use tp_hotel
  12.  
  13. define tp_hotel p_rRoomList CreateThingListProp().
  14.  
  15. /****/
  16.  
  17. define tp_hotel r_foyer CreateThing(r_indoors).
  18. SetupRoom(r_foyer, "in the hotel foyer",
  19.     "There is a receptionist behind a desk to the east, and a restaurant"
  20.     " to the west. There is a lift to the north, and the exit is south.").
  21. r_foyer@p_rNorthDesc:="To the north is a modern looking elevator.".
  22. r_foyer@p_rEastDesc :="To the east is the reception desk. A young lady "
  23.     "sits behind it, reading a magazine. There is a sign on the desk.".
  24. r_foyer@p_rWestDesc :="To the west is a door leading to the restaurant.".
  25. r_foyer@p_rSouthDesc:="To the south is a door which leads outside.".
  26. r_foyer@p_rExitDesc:="To the south is a door which leads outside.".
  27. Connect(r_en2,r_foyer,D_NORTH).
  28. UniConnect(r_en2, r_foyer, D_ENTER).
  29. UniConnect(r_foyer, r_en2, D_EXIT).
  30. r_en2@p_rScenery:="door;plain,wooden,wood.building".
  31. r_foyer@p_rScenery:="entry.foyer;large.desk;reception.door;west,south.magazine;colorful,looking.receptionist.lady".
  32.  
  33. define tp_hotel r_restaurant CreateThing(r_indoors).
  34. SetupRoom(r_restaurant, "in the hotel restaurant", "** add a description here **").
  35. Connect(r_foyer,r_restaurant,D_WEST).
  36. UniConnect(r_restaurant, r_foyer, D_EXIT).
  37. r_restaurant@p_rScenery:="tables;large".
  38.  
  39. define tp_hotel r_lift CreateThing(r_indoors).
  40. SetupRoom(r_lift, "in the hotel lift", "The interior of the lift has a "
  41.     "black marble-like finish, which is covered in greasy smears. There "
  42.     "is a control panel with two buttons.").
  43. Connect(r_foyer,r_lift,D_NORTH).
  44. r_lift@p_rScenery:="panel;metal,control.finish;black,marble.marble;black.smear;greasy".
  45.  
  46. /****/
  47.  
  48. define tp_hotel proc FindRoom(thing who)thing:
  49.   int count;
  50.   thing room;
  51.   list thing lt;
  52.  
  53.   lt:=r_lift@p_rRoomList;
  54.   count:=Count(lt)-1;
  55.   while count>-1 do
  56.     room:=lt[count];
  57.     if room@p_oCarryer=who then
  58.       count:=-2;
  59.     else
  60.       count:=count-1;
  61.     fi;
  62.   od;
  63.   if count=-1 then
  64.     nil
  65.   else
  66.     room
  67.   fi
  68. corp;
  69.  
  70. /****/
  71.  
  72. /* Create lift button */
  73. define tp_hotel o_button CreateThing(nil).
  74. SetThingStatus(o_button, ts_public).
  75. o_button@p_oInvisible:=true.
  76. o_button@p_oNotGettable:=true.
  77.  
  78. define tp_hotel o_button1 CreateThing(o_button).
  79. o_button1@p_oName := "button;top.1,1,top,first;button".
  80. o_button1@p_oReadString := "The button is labeled '1'.".
  81. AddTail(r_lift@p_rContents, o_button1).
  82.  
  83. define tp_hotel o_buttonG CreateThing(o_button).
  84. o_buttonG@p_oName := "button;bottom,2,G.G,bottom,2;button".
  85. o_buttonG@p_oReadString := "The button is labeled 'G'.".
  86. AddTail(r_lift@p_rContents, o_buttonG).
  87.  
  88. define tp_hotel proc moveLift(thing room)bool:
  89.   if r_lift@p_rSouth~=room then
  90.     /* lift needs to move */
  91.     if room=r_foyer then
  92.       /* going down */
  93.       ABPrint(r_lift,nil,nil,"The lift descends and stops gently at the ground floor. The doors open to reveal the foyer.\n");
  94.     else
  95.       /* going up */
  96.       ABPrint(r_lift,nil,nil,"The lift ascends for a few seconds before stopping. There only seems to be one room on this floor.\n");
  97.     fi;
  98.     r_lift@p_rSouth:=room;
  99.     true
  100.   else
  101.     /* lift is already there */
  102.     false
  103.   fi
  104. corp;
  105.  
  106. define tp_hotel proc pressButton()status:
  107.   thing room;
  108.  
  109.   if It()=o_buttonG then
  110.     if moveLift(r_foyer)=false then
  111.       Print("Nothing happens.\n");
  112.     fi;
  113.   else
  114.     room:=FindRoom(Me());
  115.     if room~=nil then
  116.       if moveLift(room)=false then
  117.     Print("The button remains lit.\n");
  118.       fi;
  119.     else
  120.       Print("The button lights, blinks twice, then goes out.\n");
  121.     fi;
  122.   fi;
  123.   succeed
  124. corp;
  125. o_button@p_oPushChecker := pressButton.
  126.  
  127. define tp_hotel proc descButton()string:
  128.   thing it,me,room;
  129.   bool b;
  130.   string s;
  131.  
  132.   it:=It();
  133.  
  134.   if it=o_buttonG then
  135.     b:=(r_lift@p_rSouth=r_foyer);
  136.     s:="G";
  137.   else
  138.     b:=(r_lift@p_rSouth~=r_foyer);
  139.     s:="1";
  140.   fi;
  141.  
  142.   if b=true then
  143.     "The button, labeled '"+s+"', is lit up brightly."
  144.   else
  145.     "The button, labeled '"+s+"', is not lit."
  146.   fi
  147. corp;
  148. o_button@p_oDescAction:= descButton.
  149.  
  150. define tp_hotel o_sign CreateThing(nil).
  151. o_sign@p_oNotGettable:=true.
  152. o_sign@p_oInvisible:=true.
  153. o_sign@p_oName:="sign".
  154. o_sign@p_oDesc:="The sign is a piece of white card folded in half.".
  155. o_sign@p_oReadString:="The sign reads 'One room only per customer. Register at the desk.'".
  156. AddTail(r_foyer@p_rContents,o_sign).
  157.  
  158. define tp_hotel proc exitToLift()status:
  159.   thing room;
  160.   bool b;
  161.  
  162.   room:=Here();
  163.   b:=moveLift(room);
  164.   continue
  165. corp;
  166. AddNorthChecker(r_foyer,exitToLift,false).
  167.  
  168. define tp_hotel proc nameRoom()string:
  169.   thing room;
  170.   room:=Here();
  171.   if room@p_oCarryer=Me() then
  172.     "in your room"
  173.   else
  174.     "in " + room@p_oCarryer@p_pName + "'s room"
  175.   fi
  176. corp;
  177.  
  178. /****/
  179.  
  180. /* Create the rooms */
  181. r_lift@p_rRoomList:=CreateThingList().
  182.  
  183. /****/
  184.  
  185. define tp_hotel defaultRoom CreateThing(r_indoors).
  186. defaultRoom@p_rDesc:="There is a double bed and a wardrobe.".
  187. defaultRoom@p_rNameAction:=nameRoom.
  188. defaultRoom@p_rScenery:="bed;double.wardrobe;plain,wooden".
  189. UniConnect(defaultRoom, r_lift, D_EXIT).
  190. UniConnect(defaultRoom, r_lift, D_NORTH).
  191. AddNorthChecker(defaultRoom,exitToLift,false).
  192.  
  193.  
  194. /****/
  195.  
  196.  
  197. define tp_hotel proc roomRegister()bool:
  198.   thing me,room;
  199.  
  200.   me := Me();
  201.   room:=FindRoom(me);
  202.   if room=nil then
  203.     room:=CreateThing(defaultRoom);
  204.     room@p_rContents := CreateThingList();
  205.     room@p_oCarryer:=me;
  206.     SetThingStatus(room, ts_public);
  207.  
  208.     AddTail(r_lift@p_rRoomList,room);
  209.     Print("You walk up to the counter to register.  A receptionist get up "
  210.       "from her seat, and helps you fill out all of the forms in "
  211.       "triplicate.  She then tells you that your room is on the "
  212.       "first floor, says goodbye, and returns to her magazine.\n");
  213.     if not me@p_pHidden then
  214.       OPrint(me@p_pName + " walks to the reception area and speaks to the receptionist.\n");
  215.     else
  216.       OPrint("The receptionist gets up and speaks into thin air!\n");
  217.     fi;
  218.     true
  219.   else
  220.     Print("You already have a room here!\n");
  221.     if not me@p_pHidden then
  222.       OPrint(me@p_pName + " walks up to the counter, but is turned away.\n");
  223.     fi;
  224.     false
  225.   fi
  226. corp;
  227.  
  228. r_foyer@p_rRegisterAction := roomRegister.
  229.  
  230. /****/
  231.  
  232. unuse t_util.
  233. unuse t_base.
  234. unuse t_roomTypes.
  235. unuse t_streets.
  236. unuse tp_hotel
  237.  
  238.  
  239.